{% extends 'base/base.html' %}

{% block title %}监测数据详情 - 环保监测数据管理系统{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h1 class="h2">监测数据详情</h1>
        <div>
            <a href="{% url 'monitoring:data_list' %}" class="btn btn-secondary">
                <i class="fas fa-arrow-left"></i> 返回列表
            </a>
            <a href="{% url 'monitoring:data_update' data.id %}" class="btn btn-primary">
                <i class="fas fa-edit"></i> 编辑
            </a>
            <a href="{% url 'monitoring:data_delete' data.id %}" class="btn btn-danger">
                <i class="fas fa-trash"></i> 删除
            </a>
        </div>
    </div>
    
    <div class="card shadow mb-4">
        <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-primary">基本信息</h6>
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-md-6">
                    <table class="table table-borderless">
                        <tr>
                            <th style="width: 150px;">ID：</th>
                            <td>{{ data.id }}</td>
                        </tr>
                        <tr>
                            <th>监测类别：</th>
                            <td>{{ data.category.name }}</td>
                        </tr>
                        <tr>
                            <th>监测地点：</th>
                            <td>{{ data.location }}</td>
                        </tr>
                        <tr>
                            <th>监测值：</th>
                            <td>{{ data.value }} {{ data.unit }}</td>
                        </tr>
                        <tr>
                            <th>状态：</th>
                            <td>
                                {% if data.status == 'normal' %}
                                <span class="badge bg-success">正常</span>
                                {% elif data.status == 'warning' %}
                                <span class="badge bg-warning">警告</span>
                                {% elif data.status == 'danger' %}
                                <span class="badge bg-danger">危险</span>
                                {% endif %}
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="col-md-6">
                    <table class="table table-borderless">
                        <tr>
                            <th style="width: 150px;">监测时间：</th>
                            <td>{{ data.measured_at|date:"Y-m-d H:i:s" }}</td>
                        </tr>
                        <tr>
                            <th>创建人：</th>
                            <td>{{ data.created_by.username }}</td>
                        </tr>
                        <tr>
                            <th>创建时间：</th>
                            <td>{{ data.created_at|date:"Y-m-d H:i:s" }}</td>
                        </tr>
                        <tr>
                            <th>更新时间：</th>
                            <td>{{ data.updated_at|date:"Y-m-d H:i:s" }}</td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    </div>
    
    {% if data.notes %}
    <div class="card shadow mb-4">
        <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-primary">备注</h6>
        </div>
        <div class="card-body">
            <p>{{ data.notes|linebreaks }}</p>
        </div>
    </div>
    {% endif %}
</div>
{% endblock %} 